import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path:'',
      redirect: '/main',
    },
    {
      path: '/main',
      name: 'main',
      component: () => import('../views/main/main.vue'),
      meta: { title: '入口' },
    },
    {
      path: '/',
      name: 'basic',
      component: () => import('../views/layout/layout.vue'),
      meta: { title: '基础' },
      children:[
        {
          path: '/home',
          name: 'home',
          component: () => import('../views/home/home.vue'),
          meta: { title: '主页' }
        },
        {
          path: '/exam',
          name: 'exam',
          component: () => import('../views/exam/exam.vue'),
          meta: { title: '答题' }
        },
        {
          path: '/about',
          name: 'about',
          component: () => import('../views/about/about.vue'),
          meta: { title: '关于' }
        },
        {
          path: '/rank',
          name: 'rank',
          component: () => import('../views/rank/rank.vue'),
          meta: { title: '排名' }
        },
        {
          path: '/analysis',
          name: 'analysis',
          component: () => import('../views/analysis/analysis.vue'),
          meta: { title: '分析' }
        },
      ]
    },
   
    {
      path: '/login',
      name : 'login',
      component:()=> import('../views/login/index.vue'),
      meta :{ title:'登录'}
    }
  ]
})

router.beforeEach((to,from)=>{
  if(to.name=='Login'){
    
  }
})

export default router
